/*
 * =====================================================================================
 *
 *       Filename:  netHelp.h
 *
 *    Description:  net help functions.just for internal usage
 *    				some defination about net operation.
 *
 *        Version:  1.0
 *        Created:  07/12/2012 11:05:02 AM
 *       Revision:  none
 *       Compiler:  gcc/g++
 *
 *         Author:  wangtengchao , wangtengchao AT gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */

#ifndef NETHELP_H
#define NETHELP_H

#include<iostream>
#include<netinet/in.h> //for in_addr_t  htons  htonl
#include<sys/socket.h> //for socket struct sockaddr
namespace inm
{
	namespace net
    {//named rule : single function named like AbCd ---the first alpha is upper.
		using std::string;
        class InetAddr;
		// "1.2.3.4" to in_addr_t(uint32_t)
		in_addr_t InetPresentationToNumeric(const char* str);		
		// in_addr_t to "1.2.3.4"
        string InetNumericToPresentation(const in_addr_t& addr);
       // string InetNumericToPresentation(const InetAddr& inetAddr);

        bool SetNonBlock(int fd);

        int Socket(int family,int type,int protocol);
        bool Bind(int sockfd,const struct sockaddr_in& myaddr); // & not * if for socklen_t
        void Listen(int sockfd);
       // int Accept(int sockfd,struct sockaddr_in& peerAddr);// sockaddr_in   not sockaddr
        int Accept(int sockfd,InetAddr& clientAddr);
        void Close(int fd);
        ssize_t Write(int fd,const void* buf,size_t count);
        void ShutdownWrite(int fd);

	};
};




#endif
